#include "namedPipe.hpp"
int main()
{
    NamedPipe pipe("./myfifo", Creater);
    std::cout << "named pipe creat success" << std::endl;
    if(pipe.ReadOpen())
    {
        std::cout << "named pipe open success" << std::endl;
        std::string message;
        while(true)
        {
            int n = pipe.ReadFromPipe(message);
            if(n > 0)
            {
                //说明读取成功
                std::cout << "Server Say>" << message << std::endl;
            }
            else if(n == 0)
            {
                //说明写端关闭
                std::cout << "client have quited ,server quit too" << std::endl;
                break;
            }
            else
            {
                //否则说明读取管道时发生错误
                std::cout << "ReadFromPipe Error" << std::endl;
                break;
            }
        }
    }
    return 0;
}
